package com.ouc.openplatform.zykt.standardManage.service.impl;

import java.util.List;

import com.ouc.openplatform.zykt.standardManage.dao.NJ_TestStandardSubitermDAO;
import com.ouc.openplatform.zykt.standardManage.model.NJ_TestItemTemplet;
import com.ouc.openplatform.zykt.standardManage.model.NJ_TestStandardSubiterm;
import com.ouc.openplatform.zykt.standardManage.service.NJ_TestStandardSubitermService;



public class NJ_TestStandardSubitermServiceImpl implements
		NJ_TestStandardSubitermService {

	NJ_TestStandardSubitermDAO testStandardSubitermDAO;

	public NJ_TestStandardSubitermDAO getTestStandardSubitermDAO() {
		return testStandardSubitermDAO;
	}

	public void setTestStandardSubitermDAO(
			NJ_TestStandardSubitermDAO testStandardSubitermDAO) {
		this.testStandardSubitermDAO = testStandardSubitermDAO;
	}

	@Override
	public List<NJ_TestStandardSubiterm> searchAllTestStandardSubiterm(
			int standardItermID) {
		// TODO Auto-generated method stub
		return testStandardSubitermDAO
				.searchAllTestStandardSubiterm(standardItermID);
	}

	@Override
	public int insertTestStandardSubiterm(NJ_TestStandardSubiterm subiterm) {
		int result = 0;
		int tmp = checkName(subiterm);
		if (tmp == 0) {
			result = testStandardSubitermDAO
					.insertTestStandardSubiterm(subiterm);
			updateItemTime(subiterm.getStandardItermID());// 修改标准项时间
		}
		if (tmp != 0) {
			result = 7;
		}

		System.out.println("result:" + result);
		System.out.println("tmp:" + tmp);

		return result;
	}

	@Override
	public int editTestStandardSubiterm(NJ_TestStandardSubiterm subiterm) {
		// TODO Auto-generated method stub
		int result = testStandardSubitermDAO.editTestStandardSubiterm(subiterm);
		updateItemTime(subiterm.getStandardItermID());// 修改标准项时间
		return result;

	}

	@Override
	public int deleteTestStandardSubiterm(int id, int standarditermid) {
		// TODO Auto-generated method stub
		return testStandardSubitermDAO.deleteTestStandardSubiterm(id,
				standarditermid);
	}

	@Override
	public int updateItemTime(int id) {
		// TODO Auto-generated method stub
		return testStandardSubitermDAO.updateItemTime(id);
	}

	@Override
	public int checkName(NJ_TestStandardSubiterm subiterm) {
		return testStandardSubitermDAO.checkName(subiterm);
	}

	@Override
	public List<NJ_TestItemTemplet> getItemidByName(String name) {
		// TODO Auto-generated method stub
		return testStandardSubitermDAO.getItemidByName(name);
	}

	@Override
	public String getUsernoByName(String name) {
		// TODO Auto-generated method stub
		return testStandardSubitermDAO.getUsernoByName(name);
	}

	@Override
	public int importByExcel(NJ_TestStandardSubiterm subiterm) {
		System.out.println("biz tss 导入excel");
		return testStandardSubitermDAO.importByExcel(subiterm);
	}

	@Override
	public int insertTest(NJ_TestStandardSubiterm subiterm) {
		System.out.println("enter function insertTest");
		return testStandardSubitermDAO.insertTest(subiterm);
	}

}
